<div id="admin" style="width: 100%;height: 100%;">

					<div class="panel panel-default">
						<div class="panel-heading">
							名片列表
						</div>

						<div class="navbar-form navbar-left" role="search">
							<div class="form-group">
								<input type="text" class="form-control"  id="userid"  placeholder="请输入钱包账号">
								<input type="text" class="form-control"  id="name" placeholder="请输入姓名">
								<input type="text" class="form-control"  id="phone" placeholder="请输入电话">
							</div>
							 <button type="button" onclick="ready('','');" style="" class="btn btn-default">搜索</button>
						</div>
						<!-- /.panel-heading -->
						<div class="panel-body">
							<div class="table-responsive" style="height:600px;">
								<table class="table">
									<thead>
										<tr>
											<th style="width: 2%">#</th>
											<th style="width: 10%">岗位</th>
											<th style="width: 5%">姓名</th>
											<th style="width: 10%">QQ</th>
											<th style="width: 10%">微信</th>
											<th style="width: 10%">手机</th>
											<th style="width: 10%">支付宝</th>
											<th style="width: 28%">钱包ID</th>
										</tr>
									</thead>
									<tbody id="admin_tbody">
									
									</tbody>
								</table>
							</div>
							<!-- /.table-responsive -->
						</div>
						<!-- /.panel-body -->
					</div>

					 <div style="text-align:right">
	                    <span style="margin-right:30px;">当前是：01页</span>
	                    <ul class="pagination pagination-sm" id="paging" style="vertical-align:middle;">
						<li><a href="#">&laquo;</a></li>
						<li><a href="#">1</a></li>
						<li><a href="#">2</a></li>
						<li><a href="#">3</a></li>
						<li><a href="#">4</a></li>
						<li><a href="#">5</a></li>
						<li><a href="#">&raquo;</a></li>
				       </ul>
                    </div>
					
					
					<div class='pop' id="pop">
						<div class='box'>
							<div class="modal-header">
									交易记录详情
									<button type="button" onclick="closeWindow();" class="close" data-dismiss="modal" aria-hidden="true">×</button>
									<h4 class="modal-title" id="myModalLabel"></h4>
								</div>
								<div>
									<div><label>流水号:</label><span id="serialNumber"></span></div>
								    <div><label>交易金额:</label><span id="money"></span></div>
								    <div><label>收款方名称:</label><span id="receivablesName"></span></div>
								    <div><label>收款方账号:</label><span id="receivablesNumber"></span></div>
								    <div><label>发款方名称:</label><span id="paymentName"></span></div>
								    <div><label>发款方账号:</label><span id="paymentNumber"></span></div>
								    <div><label>交易类型:</label><span id="type"></span></div>
								    <div><label>交易状态:</label><span id="state"></span></div>
								    <div><label>交易开始时间:</label><span id="beginDate"></span></div>
								    <div><label>交易结束时间:</label><span id="endDate"></span></div>
								    <div><label>备注:</label><span id="flag"></span></div>
								    <div><label>钱包账号:</label><span id="userid"></span></div>
								    <div><label>操作:</label><span id="operate"></span></div>
								    <div><label>操作标识:</label><span id="operateflag"></span></div>
								    <div><label>未知字符:</label><span id="coinNo"></span></div>
								    <div><label>交易地址:</label><span id="receivablesAddress"></span></div>
								    <div><label>备注:</label><span id="remark"></span></div>
								    <div><label>用户名称:</label><span id="userName"></span></div>
								</div>
								<div class="modal-footer">
									<button id="closeW" type="button" class="btn btn-default" onclick="closeWindow();">关闭</button>
								</div>
							</div>
							
						</div>
					</div>
					

<script type="text/javascript">

	//页面加载执行数据渲染	
	$(function(){ 
		ready("","");
	}); 
	
	
	//界面加载方法
	function ready(currentPageNum,totle){
		
		// 分页参数设定
		if(currentPageNum=="" || currentPageNum==null){
			currentPageNum=1;
		}
		
		// 分页参数设定
		if(totle=="" || totle==null){
			totle=10;
		}
		var userid=$("#userid").val();
		var phone=$("#phone").val();
		var name=$("#name").val();
		var data={'currentPageNum':currentPageNum,'perPageSize':totle,'userId':userid,'phone':phone,'name':name};
		$.ajax({  
		    type:'post',    
		    url:'/BusinessCard/selectByPrimaryAll.do',  
		    data:data,  
		    cache:false,  
		    dataType:'json',  
		    success:function(data){  
		    	Data_assembly(data);
		    	footer(data.data.totalPageNum,data.data.currentPageNum);
		    }  
		  });
	}
	
	//数据组装方法
	function Data_assembly(data){
		  console.log(data);
		  console.log(tbody);
		  var tbody=data.data.entitys;
		  var html="";
		  var b=1;
		  for(var i=0;i<tbody.length;i++){
			  html+='<tr>';
			  html+='<td>'+b+'</td>';
			  html+='<td>'+tbody[i].job+'</td>';
			  html+='<td>'+tbody[i].name+'</td>';
			  html+='<td>'+tbody[i].qq+'</td>';
			  html+='<td>'+tbody[i].wechat+'</td>';
			  html+='<td>'+tbody[i].phone+'</td>';
			  html+='<td>'+tbody[i].alipay+'</td>';
			  html+='<td>'+tbody[i].userId+'</td>';
			 // html+='<td>'+tbody[i].state+'</td>';
			  html+='</tr>';
			  b++;
		  }
		  
		  $("#admin_tbody").html(html);
	}
	
	
	//添加用户
	function addAdmin(){
		var userName=$("#userName").val();
		var phone=$("#phone").val();
		var account=$("#account").val();
		var state=$("#state").val();
		alert(state);
		var password=$("#password").val();
		var errText="";
		var errCode="0";
		//数据校验
		if(userName==null || userName=='' || userName.length>10){
			  $("#userNameErr").html("用户名不能为空,且长度不能超过十个字段");
			  errCode="1";
		}else{
			 $("#userNameErr").html("");
		}
		
		//数据校验
		if(phone==null || phone=='' || phone.length>20){
			  $("#phoneErr").html("用户名不能为空,且长度不能超过二十个字段");
			  errCode="1";
		}else{
			 $("#phoneErr").html("");
		}
		
		//数据校验
		if(account==null || account=='' || account.length>20){
			  $("#accountErr").html("用户名不能为空,且长度不能超过二十个字段");
			  errCode="1";
		}else{
			 $("#accountErr").html("");
		}
		
		//数据校验
		if(password==null || password=='' || password.length>20){
			  $("#passwordErr").html("用户名不能为空,且长度不能超过二十个字段");
			  errCode="1";
		}else{
			 $("#passwordErr").html("");
		}
		
		if(errCode=="1"){
			return;
		}
				
		var data={'userName':userName,'phone':phone,'account':account,'state':state,'password':password};	
		$.ajax({  
		    type:'post',    
		    url:'/Admin/insert.do',  
		    data:data,  
		    cache:false,  
		    dataType:'json',  
		    success:function(data){  
		    	alert(data.msg);
		    	ready("","");
		    	closeWindow();
		    	
		    }  
		  });
	
	}
	
	//删除
	function deleteAdmin(id){
		if(id==null || id==''){
			return;
		}
		var data={'id':id};
		$.ajax({  
		    type:'post',    
		    url:'/Admin/deleteByPrimaryKey.do',  
		    data:data,  
		    cache:false,  
		    dataType:'json',  
		    success:function(data){  
		    	alert(data.msg);
		    	ready("","");
		    }  
		  });
	}
	
	//查看记录详情
	function detailsSelect(id){
		
		var data={'id':id};
		
		$.ajax({  
		    type:'post',    
		    url:'/Bill/findUserNameBill.do',  
		    data:data,  
		    cache:false,  
		    dataType:'json',  
		    success:function(data){ 
		    	 var tbody=data.data.entitys;
		    	 if(data.code==0){
		    		 $("#serialNumber").html(tbody[0].serialNumber);
		    		 $("#money").html(tbody[0].money);
		    		 $("#receivablesName").html(tbody[0].receivablesName);
		    		 $("#receivablesNumber").html(tbody[0].receivablesNumber);
		    		 $("#paymentName").html(tbody[0].paymentName);
		    		 $("#paymentNumber").html(tbody[0].paymentNumber);
		    		 if(tbody[0].type==0){
		    			 $("#type").html("银行卡");
		    		 }else if(tbody[0].type==1){
		    			 $("#type").html("余额");
		    		 }else{
		    			 $("#type").html("未知");
		    		 }
		    		 
		    		 if(tbody[0].state==0){
		    			 $("#state").html("转账中");
		    		 }else if(tbody[0].type==1){
		    			 $("#state").html("转账成功");
		    		 }else{
		    			 $("#state").html("未知");
		    		 }
		    		
		    		 $("#beginDate").html(tbody[0].beginDate);
		    		 $("#endDate").html(tbody[0].endDate);
		    		 $("#flag").html(tbody[0].flag);
		    		 $("#userid").html(tbody[0].userid);
		    		 $("#operate").html(tbody[0].operate);
		    		 $("#operateflag").html(tbody[0].operateflag);
		    		 $("#coinNo").html(tbody[0].coinNo);
		    		 $("#receivablesAddress").html(tbody[0].receivablesAddress);
		    		 $("#remark").html(tbody[0].remark);
		    		 $("#userName").html(tbody[0].userName);
				     closeWindow();
		    	 }else{
		    		 alert(data.msg);
		    	 }
		    	
		    }  
		  });
	}
	
	
	//关闭弹出层
	function closeWindow(){
		$("#pop").fadeToggle();
	}

	
	//分页页脚生成方法
	//dataSize 总页数
	//unmSize 当前所在页数
	function footer(dataSize, unmSize) {
		$("#paging").find("li").remove();
		var html = '<li><a href="javascript:skip(1,' + unmSize + ',' + dataSize
				+ ');">&laquo;</a></li>';
		$("#paging").append(html);

		var number = 12;

		// 判断生成前面部分页脚
		if (unmSize > 5) {
			html = '<li><a href="javascript:skip(0,1);">1</a></li>';
			$("#paging").append(html);
			html = '<li><a href="javascript:skip(0,2);">2</a></li>';
			$("#paging").append(html);
			html = '<li><a href="javascript:void(0);">...</a></li>';
			$("#paging").append(html);
			number = number - 3;
			// 循环生成前半部分
			for (var i = 3; i > 0; i--) {
				if (unmSize - 2 - i > 3) {
					for (i; i > 0; i--) {
						number--;
						var finlSize = unmSize;
						finlSize = finlSize - i;
						html = '<li><a href="javascript:skip(0,' + finlSize + ','
								+ dataSize + ');">' + finlSize + '</a></li>';
						$("#paging").append(html);
					}
					break;
				}
			}

		} else {
			for (var i = 1; i < unmSize; i++) {
				number--;
				html = '<li><a href="javascript:skip(0,' + i + ',' + dataSize
						+ ');">' + i + '</a></li>';
				$("#paging").append(html);
			}
		}

		// 生成当前页
		html = '<li><a style="color:#000;" href="javascript:skip(0,' + unmSize
				+ ',' + dataSize + ');">' + unmSize + '</a></li>';
		$("#paging").append(html);

		// 循环生成后半部分
		for (var i = number; i > 0; i--) {

			if (unmSize + i <= dataSize) {
				number = i;
				var size = unmSize;
				for (i; i > 0; i--) {
					size = size + 1;
					html = '<li><a href="javascript:skip(0,' + size + ','
							+ dataSize + ');">' + size + '</a></li>';
					$("#paging").append(html);
				}
			}
		}

		// 判断生成最后部分页脚
		var endNumber = dataSize - unmSize - number;
		if (endNumber > 3) {
			// 尾部长度超出三个，用省略号代替
			html = '<li><a href="javascript:void(0);">...</a></li>';
			$("#paging").append(html);
			var endSize = dataSize - 1;
			html = '<li><a href="javascript:skip(0,' + endSize + ');">' + endSize
					+ '</a></li>';
			$("#paging").append(html);
			html = '<li><a href="javascript:skip(0,' + dataSize + ');">' + dataSize
					+ '</a></li>';
			$("#paging").append(html);

		} else {
			// 尾部长度没有超出三个，不用省略号
			for (var i = endNumber; i > 0; i--) {
				html = '<li><a href="javascript:skip(0,' + dataSize + ');">'
						+ dataSize + '</a></li>';
				$("#paging").append(html);
				dataSize = dataSize - i;
			}
		}
		html = '<li><a href="javascript:skip(2,' + unmSize + ',' + dataSize
				+ ');">&raquo;</a></li>';
		$("#paging").append(html);
	}



	//分页前置配参执行方法
	function skip(type, num, dataSize) {
		if (type == 1) {
			if (num > 1) {
				num = num - 1
			}else{
				return;
			}
			ready(num,10);
		} else if (type == 2) {

			if (num < dataSize) {
				num = num + 1
				var data={'currentPageNum':num};
				ready(num,10);
			}else{
				return;
			}
		} else if (type == 0) {
			ready(num,10);
		} else {

		}

	}
</script>